/**
 * @Author 12629
 * @Date 2022/4/28 18:18
 * @Description：
 */
public class Test {

    public static int fac(int n) {
        if(n == 1) {
            return 1;
        }
        int tmp = n * fac(n-1);
        return tmp;
    }

    /**
     * 顺序打印
     * @param n
     */
    public static void print(int n) {
        if(n < 10) {
            System.out.println(n);
        }else {
            print(n/10);
            System.out.println(n%10);
        }
    }

    public static int sum (int n) {
        if(n == 1) {
            return 1;
        }else {
            int tmp = n + sum(n-1);
            return tmp;
        }
    }

    public static int sumEvery(int n) {
        if(n < 10) {
            return n;
        }
        int tmp = n%10+sumEvery(n/10);
        return tmp;
    }

    public static int count = 0;
    public static int fib(int n) {
        if(n == 1 || n == 2) {
            //count++;
            return 1;
        }
        if(n == 3) {
            count++;
        }
        int tmp = fib(n-1)+fib(n-2);
        return tmp;
    }

    public static int fib2(int n) {
        if(n <= 0) {
            return -1;
        }
        if(n == 1 || n == 2) {
            return 1;
        }
        int f1 = 1;
        int f2 = 1;
        int f3 = -1;
        for (int i = 3; i <= n; i++) {
            f3 = f1+f2;
            f1 = f2;
            f2 = f3;
        }
        return f3;
    }

    public static void main(String[] args) {
        /*System.out.println(fib2(3));
        System.out.println(fib2(4));
        System.out.println(fib2(5));*/
        int ret = fib(41);
        System.out.println(ret+" 次数："+Test.count);
    }


    public static void func(int a) {
        if(a == 1) {
            return;
        }
        func(a-1);
    }

    public static void main2(String[] args) {
        func(3);
    }


    public static void main1(String[] args) {
        int[] array = {1,2,3,2,1};
        int sum = 0;
        for (int i = 0; i < 5; i++) {
            sum = sum ^ array[i];
        }
        System.out.println(sum);
    }
}
